﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using YasharEl.Infrastructure.TaskEngine.Assignments;

namespace YasharEl.Infrastructure.TaskEngine.DomainModel
{
    [ContractClass(typeof(TaskEngineProcessorContract))]
    public interface ITaskProcessor
    {
        ITask AddNewTask(long applicationId, long userId, string name, string description,
            long? assignTo, Guid initiatorCorrelationId, ParticipantType participantType,
            long taskDefinitionId, DateTime? reminderDate,
            TaskPriority priority, List<ITaskAction> actions);

        ITask CancelTask(long applicationId, long userId, long taskInstanceId, string comment);
    }

    [ContractClassFor(typeof(ITaskProcessor))]
    internal abstract class TaskEngineProcessorContract : ITaskProcessor
    {
        public ITask AddNewTask(long applicationId, long userId, string name, string description,
            long? assignTo, Guid initiatorCorrelationId, ParticipantType participantType, long taskDefinitionId,
            DateTime? reminderDate, TaskPriority priority, List<ITaskAction> actions)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(name), "name could not be null or empty.");
            Contract.Requires<ArgumentNullException>(taskDefinitionId > 0, "taskDefinitionId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(participantType != null, "participantType could not be null.");
            Contract.Requires<ArgumentNullException>(priority != null, "priority could not be null.");

            return default(ITask);
        }

        public ITask CancelTask(long applicationId, long userId, long taskInstanceId, string comment)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(taskInstanceId > 0, "taskInstanceId must be valid positive numeric value.");

            return default(ITask);
        }
    }
}
